package com.lsw.jgyf.ui.activity;

import android.widget.ImageView;
import android.widget.TextView;

import com.lsw.jgyf.R;
import com.lsw.jgyf.model.OrderDetailsModel;
import com.lsw.jgyf.ui.base.activity.TitleBarActivity;
import com.lsw.jgyf.util.GlideUtils;
import com.lsw.ninegridimageview.Image;

import butterknife.BindView;

/**
 * Created by lsw on 2018/7/12.
 */

public class OrderDetailsActivity extends TitleBarActivity<OrderDetailsPresenter> implements OrderDetailsContract.View {

    String id;
    @BindView(R.id.tv_name)
    TextView tv_name;
    @BindView(R.id.tv_sex)
    TextView tv_sex;
    @BindView(R.id.tv_phone)
    TextView tv_phone;
    @BindView(R.id.tv_id_number)
    TextView tv_id_number;
    @BindView(R.id.tv_youxiaoqi)
    TextView tv_youxiaoqi;
    @BindView(R.id.tv_jigou)
    TextView tv_jigou;
    @BindView(R.id.iv_id_front_img)
    ImageView iv_id_front_img;
    @BindView(R.id.iv_id_back_img)
    ImageView iv_id_back_img;
    @BindView(R.id.tv_bank_name)
    TextView tv_bank_name;
    @BindView(R.id.tv_bank_number)
    TextView tv_bank_number;
    @BindView(R.id.iv_bankcard)
    ImageView iv_bankcard;
    @BindView(R.id.tv_taocan)
    TextView tv_taocan;
    @BindView(R.id.tv_pinpai)
    TextView tv_pinpai;
    @BindView(R.id.tv_phone_name)
    TextView tv_phone_name;
    @BindView(R.id.tv_fenqigongsi)
    TextView tv_fenqigongsi;
    @BindView(R.id.tv_price)
    TextView tv_price;
    @BindView(R.id.tv_qishu)
    TextView tv_qishu;
    @BindView(R.id.tv_shoufu)
    TextView tv_shoufu;
    @BindView(R.id.tv_zonge)
    TextView tv_zonge;
    @BindView(R.id.tv_yuefu)
    TextView tv_yuefu;
    @BindView(R.id.tv_status)
    TextView tv_status;

    @Override
    protected void initInjector() {
        mActivityComponent.inject(this);
    }

    @Override
    protected void initEventAndData() {
        id = getIntent().getStringExtra("id");
        mPresenter.getData(id);
    }

    @Override
    protected int setContentLayoutView() {
        return R.layout.activity_order_details;
    }

    @Override
    public void setData(OrderDetailsModel model) {
        if (model != null) {
            tv_name.setText(model.getUser().getUser_name());
            tv_sex.setText(model.getUser().getSex());
            tv_phone.setText(model.getUser().getMobile());
            tv_id_number.setText(model.getUser().getId_number());
            tv_youxiaoqi.setText(model.getUser().getIssue_time() + "~" + model.getUser().getEnd_time());
            tv_jigou.setText(model.getUser().getIssue());
            GlideUtils.loadImageView(mContext, model.getUser().getId_front_img(), iv_id_front_img);
            GlideUtils.loadImageView(mContext, model.getUser().getId_back_img(), iv_id_back_img);
            GlideUtils.loadImageView(mContext, model.getBank_card().getCard_img(), iv_bankcard);
            tv_bank_name.setText(model.getBank_card().getBank_name());
            tv_bank_number.setText(model.getBank_card().getBank_card_number());
            tv_taocan.setText(model.getPackageX());
            tv_pinpai.setText(model.getBrand_name());
            tv_phone_name.setText(model.getPhone_name());
            tv_fenqigongsi.setText(model.getCompany_name());
            tv_price.setText(model.getPrice());
            tv_qishu.setText(model.getPeriods());
            tv_shoufu.setText(model.getFirst_money());
            tv_zonge.setText(model.getReal_money());
            tv_yuefu.setText(model.getMonthly_supply());
            if (model.getStatus() == 1) {
                tv_status.setText("待审核");
            } else if (model.getStatus() == 2) {
                tv_status.setText("已审核");
            } else if (model.getStatus() == 3) {
                tv_status.setText("审核拒绝");
            }

        }
    }

    @Override
    protected void setActionBarDetail() {

    }

    @Override
    public void openlogin() {
        OpenLogin();
    }
}
